//
//  PersonalCenterItemView.m
//  CreditHub
//
//  Created by chenglang on 2024/9/23.
//

#import "PersonalCenterItemView.h"
#import "WebViewController.h"
#import "SettingViewController.h"

@implementation PersonalCenterItemView
- (void)setDicInfo:(NSDictionary *)dicInfo{
    _dicInfo = dicInfo;
    self.labelTitle.text = CHString(dicInfo[@"outside"]);
    [[ImageLoader sharedInstance] loadImageFromURL:[NSURL URLWithString:dicInfo[@"crept"]] imageView:self.imageViewIcon completion:^(UIImage * _Nonnull image, NSError * _Nonnull error) {
            
    }];
}
- (IBAction)clickItem:(id)sender {
    
    if(self.dicInfo.count == 0){
        return;
    }
    NSString *url  = self.dicInfo[@"faint"];
    if ([url length] >= 4) {
        NSString *substring = [url substringToIndex:4];
        if ([substring isEqualToString:@"http"]) {
            WebViewController *webView = [[WebViewController alloc] init];
            webView.url = url;
            [[UIView xhl_getTopViewController].navigationController pushViewController:webView animated:YES];
        } else {
            
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url] options:@{} completionHandler:^(BOOL success) {
                
            }];
            
        }
    }
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
